package com.it.util;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class SpringPicConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry){
        registry.addResourceHandler("/files/images/SingerImg/**").addResourceLocations(
                "file:" + System.getProperty("user.dir")+System.getProperty("file.separator")+"files"
                +System.getProperty("file.separator") + "images" + System.getProperty("file.separator") + "SingerImg"
                + System.getProperty("file.separator")
        );

        registry.addResourceHandler("/files/images/UserImg/**").addResourceLocations(
                "file:" + System.getProperty("user.dir")+System.getProperty("file.separator")+"files"
                        +System.getProperty("file.separator") + "images" + System.getProperty("file.separator") + "UserImg"
                        + System.getProperty("file.separator")
        );

        registry.addResourceHandler("/files/images/SongImg/**").addResourceLocations(
                "file:" + System.getProperty("user.dir")+System.getProperty("file.separator")+"files"
                        +System.getProperty("file.separator") + "images" + System.getProperty("file.separator") + "SongImg"
                        + System.getProperty("file.separator")
        );

        registry.addResourceHandler("/files/images/SongListImg/**").addResourceLocations(
                "file:" + System.getProperty("user.dir")+System.getProperty("file.separator")+"files"
                        +System.getProperty("file.separator") + "images" + System.getProperty("file.separator") + "SongListImg"
                        + System.getProperty("file.separator")
        );

        registry.addResourceHandler("/files/Songs/**").addResourceLocations(
                "file:" + System.getProperty("user.dir")+System.getProperty("file.separator")+"files"
                        +System.getProperty("file.separator") + "Songs" + System.getProperty("file.separator")
        );

        registry.addResourceHandler("/files/images/ArticleImg/**").addResourceLocations(
                "file:" + System.getProperty("user.dir")+System.getProperty("file.separator")+"files"
                        +System.getProperty("file.separator") + "Songs" + System.getProperty("file.separator")
        );

        registry.addResourceHandler("/files/images/ArticleCoverImg/**").addResourceLocations(
                "file:" + System.getProperty("user.dir")+System.getProperty("file.separator")+"files"
                        +System.getProperty("file.separator") + "images" + System.getProperty("file.separator")
                + "ArticleCoverImg" + System.getProperty("file.separator")
        );
    }

}
